import {RouterMount,createRouter} from 'uni-simple-router';
import store from "store";
import route from '../uni_modules/vk-uview-ui/libs/function/route';

const router = createRouter({
    platform: process.env.VUE_APP_PLATFORM,  
    routes: [
		{
		  path: "/pages/index/index",
		  alias:"/",
		  name: "Home",
		},
		{
		  path: "/pages/index/main",
		  name: "Main",
		},
		{
		  path: "/pages/index/costDetails",
		  name: "CostDetails",
		},
		{
			path: "/pages/index/monitor",
			name:"Monitor",
		},
		{
		  path: "/pages/index/step",
		  name: "Step",
		},
		{
		  path: "/pages/index/casedata",
		  name: "Casedata",
		},
		{
		  path: "/pages/index/filelist",
		  name: "FileList",
		},
		{
		  path: "/pages/index/pdf",
		  name: "Pdf",
		},
		{
		  path: "/pages/index/forget",
		  name: "Forget",
		},
		{
		  path: "/pages/index/steptwo",
		  name: "StepTwo",
		},
		{
		  path: "/pages/index/tasklog",
		  name: "TaskLog",
		},
		{
		  path: "/pages/index/logdetail",
		  name: "LogDetail",
		},
		{
		  path: "/pages/index/message",
		  name: "Message",
		},
		{
		  path: "/pages/index/viewlog",
		  name: "ViewLog",
		},
		{
		  path: "/pages/index/addtask",
		  name: "AddTask",
		},
		{
		  path: "/pages/contact/index",
		  name: "Contacts",
		},
		{
		  path: "/pages/set/index",
		  name: "Setting",
		},
		{
		  path: "/pages/file/index",
		  name: "Files",
		},
		{
		  path: "/pages/live/index",
		  name: "Live",
		},
		{
		  path: "/pages/live/playbacklist",
		  name: "Playbacklist",
		},
		{
		  path: "/pages/live/playback",
		  name: "Playback",
		},
		{
		  path: "/pages/live/pics",
		  name: "Pics",
		},
		{
		  path: "/pages/checkForm/index",
		  name: "CheckForm",
		},
		{
		  path: "/pages/checkForm/forms",
		  name: "AddForms",
		}, 
		{
		  path: "/pages/checkForm/answerPage",
		  name: "Answer",
		},
		{
		  path: "/pages/checkForm/detailPage",
		  name: "DetailPage",
		},
		{
		  path: "/pages/messages/index",
		  name: "Messages",
		},
		{
		  path: "/pages/checkForm/fragment/addOrEditFragment",
		  name: "AddOrEditFragment",
		}
	]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
	let ToName = to.name;
	if(ToName==='Home'||ToName==='Forget' || ToName === 'Live'){
		next();
	}else{
		const token = uni.getStorageSync("userToken")
		const islogin = uni.getStorageSync("islogin")
		if(!islogin){
			uni.showToast({
				title:"你还未登录",
				mask:true,
				icon:'none',
			})
			setTimeout(()=>{
				next({
				     path: '/pages/index/index'
				});
			},1200)
		}else{
			next();
		}
	}
	
	
    
});
// 全局路由后置守卫
router.afterEach((to, from) => {
    // console.log('跳转结束')
})

export {
    router,
    RouterMount
}